//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_spi(SotoInternal) import SotoCore

extension KinesisVideoWebRTCStorage {
    // MARK: Enums

    // MARK: Shapes

    public struct JoinStorageSessionAsViewerInput: AWSEncodableShape {
        ///  The Amazon Resource Name (ARN) of the signaling channel.
        public let channelArn: String
        ///  The unique identifier for the sender client.
        public let clientId: String

        @inlinable
        public init(channelArn: String, clientId: String) {
            self.channelArn = channelArn
            self.clientId = clientId
        }

        public func validate(name: String) throws {
            try self.validate(self.channelArn, name: "channelArn", parent: name, pattern: "^arn:(aws[a-zA-Z-]*):kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+$")
            try self.validate(self.clientId, name: "clientId", parent: name, max: 256)
            try self.validate(self.clientId, name: "clientId", parent: name, min: 1)
            try self.validate(self.clientId, name: "clientId", parent: name, pattern: "^[a-zA-Z0-9_.-]+$")
        }

        private enum CodingKeys: String, CodingKey {
            case channelArn = "channelArn"
            case clientId = "clientId"
        }
    }

    public struct JoinStorageSessionInput: AWSEncodableShape {
        ///  The Amazon Resource Name (ARN) of the signaling channel.
        public let channelArn: String

        @inlinable
        public init(channelArn: String) {
            self.channelArn = channelArn
        }

        public func validate(name: String) throws {
            try self.validate(self.channelArn, name: "channelArn", parent: name, pattern: "^arn:(aws[a-zA-Z-]*):kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+$")
        }

        private enum CodingKeys: String, CodingKey {
            case channelArn = "channelArn"
        }
    }
}

// MARK: - Errors

/// Error enum for KinesisVideoWebRTCStorage
public struct KinesisVideoWebRTCStorageErrorType: AWSErrorType {
    enum Code: String {
        case accessDeniedException = "AccessDeniedException"
        case clientLimitExceededException = "ClientLimitExceededException"
        case invalidArgumentException = "InvalidArgumentException"
        case resourceNotFoundException = "ResourceNotFoundException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize KinesisVideoWebRTCStorage
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// You do not have required permissions to perform this operation.
    public static var accessDeniedException: Self { .init(.accessDeniedException) }
    ///  Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed client calls. Try making the call later.
    public static var clientLimitExceededException: Self { .init(.clientLimitExceededException) }
    /// The value for this input parameter is invalid.
    public static var invalidArgumentException: Self { .init(.invalidArgumentException) }
    /// The specified resource is not found.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
}

extension KinesisVideoWebRTCStorageErrorType: Equatable {
    public static func == (lhs: KinesisVideoWebRTCStorageErrorType, rhs: KinesisVideoWebRTCStorageErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension KinesisVideoWebRTCStorageErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
